﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>ComObjCreate - 语法 &amp; 使用 | AutoHotkey v2</title>
<meta name="description" content="The ComObjCreate function creates a COM object." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>ComObjCreate</h1>
<p>Creates a COM object.</p>
<pre class="Syntax">ComObject := <span class="func">ComObjCreate</span>(CLSID <span class="optional">, IID</span>)</pre>

<h2 id="Parameters">参数</h2>
<dl>

  <dt>CLSID</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>CLSID or human-readable Prog ID of the COM object to create.</p>
  </dd>

  <dt>IID</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>The identifier of an interface the object supports.</p>
  </dd>

</dl>

<h2 id="Return_Value">返回值</h2>
<p>类型: <a href="../Concepts.htm#objects">对象</a> or <a href="../Concepts.htm#numbers">Integer</a></p>
<p>On failure, the function may throw an exception, exit the script or return an empty string, depending on the current <a href="ComObjError.htm">ComObjError</a> setting and <a href="ComObjError.htm#factors">other factors</a>.</p>
<p>If an IID is specified, an interface pointer is returned. The script must typically call <a href="ObjAddRef.htm">ObjRelease</a> when it is finished with the pointer.</p>
<p>Otherwise, a <a href="../Concepts.htm#references-to-objects">reference</a> to a new wrapper object usable by script is returned. See <a href="../Objects.htm#Usage_Objects">object syntax</a>.</p>

<h2 id="Related">相关</h2>
<p><a href="ComObject.htm">ComObject</a>, <a href="ComObjGet.htm">ComObjGet</a>, <a href="ComObjActive.htm">ComObjActive</a>, <a href="ComObjConnect.htm">ComObjConnect</a>, <a href="ComObjArray.htm">ComObjArray</a>, <a href="ComObjError.htm">ComObjError</a>, <a href="ComObjQuery.htm">ComObjQuery</a>, <a href="http://msdn.microsoft.com/en-us/library/dcw63t7z.aspx">CreateObject (MSDN)</a></p>

<h2 id="Examples">示例</h2>
<p>有关更多的示例列表, 请参阅后面的的论坛主题: <a href="https://www.autohotkey.com/forum/topic61509.html">https://www.autohotkey.com/forum/topic61509.html</a>.</p>
<div class="ex" id="ExIE">
<p><a href="#ExIE">#1</a></p>
<pre>ie := <b>ComObjCreate</b>("InternetExplorer.Application")
ie.Visible := true  <em>; 此语句在 IE7 中无法正常执行.</em>
ie.Navigate("https://www.autohotkey.com/")
</pre>
</div>

</body>
</html>